<!--
    软工(开发)21-1班数据库原理课程作业提交系统网站 - 管理员端页面。v1.0.0
    Copyright (c) 2022~2023 DuYu (No.202103180009), Faculty of Computer Science & Technology, Qilu University of Technology.
-->
<!doctype html>
<html lang="zh">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>管理员页面</title>
    <link href="../assets/dist/css/bootstrap.min.css" rel="stylesheet">
    <script src="../jquery-3.6.3.js"></script>
    <script src="../jquery.base64.js"></script>
    <script src="../jquery.cookie.js"></script>
    <script src="../vue.js"></script>
    <!-- 引入样式 -->
    <link rel="stylesheet" href="../elementUI/index.css">
    <!-- 引入组件库 -->
    <script src="../elementUI/index.js"></script>
    <script>
        if($.cookie('admin_password')!=null)
        {
            alert("成功登录管理员页面！");
        }
        else
        {
            const total_password=prompt('请输入管理员密码')
            $.ajax({
                url:'/isAdmin',
                type:'post',
                cache:false,
                dataType:'json',
                contentType:'application/json',
                data: JSON.stringify({
                    'password':total_password,
                 }),
                success:function (data)
                {
                    if(data.code===0 || data.code==='0')
                    {
                        $.cookie('admin_password',total_password);
                        //alert("成功登录管理员页面！");
                        window.history.go(0);
                    }
                    else
                    {
                        alert("密码错误。");
                        window.location='/';
                        return;
                    }
                },
                error:function ()
                {
                    alert("出现不明原因错误。");
                    return;
                }
            })
        }
    </script>
    <style>
      .bd-placeholder-img {
        font-size: 1.125rem;
        text-anchor: middle;
        -webkit-user-select: none;
        -moz-user-select: none;
        user-select: none;
      }

      @media (min-width: 768px) {
        .bd-placeholder-img-lg {
          font-size: 3.5rem;
        }
      }

      .b-example-divider {
        height: 3rem;
        background-color: rgba(0, 0, 0, .1);
        border: solid rgba(0, 0, 0, .15);
        border-width: 1px 0;
        box-shadow: inset 0 .5em 1.5em rgba(0, 0, 0, .1), inset 0 .125em .5em rgba(0, 0, 0, .15);
      }

      .b-example-vr {
        flex-shrink: 0;
        width: 1.5rem;
        height: 100vh;
      }

      .bi {
        vertical-align: -.125em;
        fill: currentColor;
      }

      .nav-scroller {
        position: relative;
        z-index: 2;
        height: 2.75rem;
        overflow-y: hidden;
      }

      .nav-scroller .nav {
        display: flex;
        flex-wrap: nowrap;
        padding-bottom: 1rem;
        margin-top: -1px;
        overflow-x: auto;
        text-align: center;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
      }
      .nav-link:hover
      {
          color: #0d6efd;
      }
    </style>
    <link href="dashboard.css" rel="stylesheet">
</head>
<body>
<header class="navbar navbar-dark sticky-top bg-dark flex-md-nowrap p-0 shadow">
  <a class="navbar-brand col-md-3 col-lg-2 me-0 px-3 fs-6" href="#">数据库作业收集系统</a>
  <button class="navbar-toggler position-absolute d-md-none collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#sidebarMenu" aria-controls="sidebarMenu" aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>
  </button>
  <input class="form-control form-control-dark w-100 rounded-0 border-0" type="text" placeholder="Search" aria-label="Search">
  <div class="navbar-nav">
    <div class="nav-item text-nowrap">
        <span class="nav-link px-3" id="logout">退出登录</span>
    </div>
  </div>
</header>

<div class="container-fluid">
  <div class="row">
    <nav id="sidebarMenu" class="col-md-3 col-lg-2 d-md-block bg-light sidebar collapse">
      <div class="position-sticky pt-3 sidebar-sticky">
        <ul class="nav flex-column">

          <li class="nav-item">
            <span class="nav-link" aria-current="page" id="PeopleManagement_Button" style="cursor: pointer;">
              <span data-feather="home" class="align-text-bottom"></span>
              人员管理
            </span>
          </li>

          <li class="nav-item">
            <span class="nav-link" id="AssignmentManagement_Button" style="cursor: pointer;">
              <span data-feather="file" class="align-text-bottom"></span>
              作业管理
            </span>
          </li>

          <li class="nav-item">
            <span class="nav-link" id="SubmitManagement_Button" style="cursor: pointer;">
              <span data-feather="shopping-cart" class="align-text-bottom"></span>
              提交管理
            </span>
          </li>
        </ul>
      </div>
    </nav>

    <main class="col-md-9 ms-sm-auto col-lg-10 px-md-4">

    <div id="PeopleManagement" >
      <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
        <h1 class="h2">人员管理</h1>
        <div class="btn-toolbar mb-2 mb-md-0">
          <div class="btn-group me-2">
            <button type="button" class="btn btn-sm btn-outline-secondary" id="People-SortById">学号排序</button>
            <button type="button" class="btn btn-sm btn-outline-secondary" id="People-SortByRegTime">注册时间排序</button>
          </div>
        </div>
      </div>

      <h5>已注册人员名单&nbsp;&nbsp;<button type="button" class="btn btn-danger" id="People-DeleteButton">删除人员</button></h5>
      <div class="table-responsive">
        <table class="table table-striped table-sm">
          <thead>
            <tr>
              <th scope="col">学号</th>
              <th scope="col">姓名</th>
              <th scope="col">密码</th>
              <th scope="col">注册时间</th>
            </tr>
          </thead>
          <tbody id="PeopleList">
          </tbody>
        </table>
       </div>
      </div>


      <div id="AssignmentManagement" style="display: none;">
      <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
        <h1 class="h2">作业管理</h1>
        <div class="btn-toolbar mb-2 mb-md-0">
          <div class="btn-group me-2">
            <button type="button" class="btn btn-sm btn-outline-secondary" id="DpAssignment">布置作业</button>
            <button type="button" class="btn btn-sm btn-outline-secondary" id="DeleteAssignment">删除作业</button>
          </div>
        </div>
      </div>

      <h5>当前作业清单</h5>
      <div class="table-responsive">
        <table class="table table-striped table-sm">
          <thead>
            <tr>
              <th scope="col">作业ID</th>
              <th scope="col">作业名称</th>
              <th scope="col">开始时间</th>
              <th scope="col">截止时间</th>
            </tr>
          </thead>
          <tbody id="AssignmentList">
          <!--
            <tr>
              <td>1,001</td>
              <td>random</td>
              <td>data</td>
              <td>placeholder</td>
            </tr>
            -->

          </tbody>
        </table>
       </div>
      </div>



      <div id="SubmitManagement" style="display: none;">
      <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
        <h1 class="h2">提交管理</h1>
        <div class="btn-toolbar mb-2 mb-md-0">
          <div class="btn-group me-3">
            <button type="button" class="btn btn-sm btn-outline-secondary" id="SubmitState-idF">学号优先排序</button>
            <button type="button" class="btn btn-sm btn-outline-secondary" id="SubmitState-assF">作业项优先排序</button>
            <button type="button" class="btn btn-sm btn-outline-secondary" id="SubmitState-timeF">时间优先排序</button>
          </div>
        </div>
      </div>

      <h5>已提交项目清单
          &nbsp;&nbsp;<button type="button" class="btn btn-danger" id="SS-BatchDelete">批量删除</button>
          &nbsp;&nbsp;<button type="button" class="btn btn-danger" id="SS-DownloadOne">下载文件</button>
          &nbsp;&nbsp;<button type="button" class="btn btn-danger" id="SS-DownloadAll">下载全部</button>
      </h5>
      <div class="table-responsive">
        <table class="table table-striped table-sm">
          <thead>
            <tr>
              <th scope="col">提交ID</th>
              <th scope="col">学号</th>
              <th scope="col">姓名</th>
              <th scope="col">作业ID</th>
              <th scope="col">提交时间</th>
            </tr>
          </thead>
          <tbody id="SubmitList">
          <!--
            <tr>
              <td>1,001</td>
              <td>random</td>
              <td>data</td>
              <td>placeholder</td>
              <td>text</td>
            </tr>
          -->

          </tbody>
        </table>
       </div>
      </div>


    </main>
  </div>
</div>

<script src="../assets/dist/js/bootstrap.bundle.min.js"></script>
<script>
    var password=$.cookie('admin_password');
    const PMB=$('#PeopleManagement_Button');
    const AMB=$('#AssignmentManagement_Button');
    const SMB=$('#SubmitManagement_Button');
    const PM=$('#PeopleManagement');
    const AM=$('#AssignmentManagement');
    const SM=$('#SubmitManagement');
    const PLT=$('#PeopleList');
    const ALT=$('#AssignmentList');
    const SLT=$('#SubmitList');
    var NAMELIST_ARR=null;
    var SUBMITLIST_ARR=null;

    $(document).on('click','#PeopleManagement_Button',function ()
    {
        PM.css('display','block');
        AM.css('display','none');
        SM.css('display','none');
    });
    $(document).on('click','#AssignmentManagement_Button',function ()
    {
        AM.css('display','block');
        PM.css('display','none');
        SM.css('display','none');
    });
    $(document).on('click','#SubmitManagement_Button',function ()
    {
        SM.css('display','block');
        AM.css('display','none');
        PM.css('display','none');
    });
    $(document).on('click','#People-DeleteButton',function ()
    {
        const idn=prompt('请输入将删除人员的学号：');
        const nam=prompt('请输入将删除人员的姓名：');
        const adp=prompt('请输入管理员密码：');
        const f=confirm('您是否删除该人员？该操作不可撤销。');
        if(f===false)
        {
            alert("删除人员操作已取消。");
            return;
            return;
        }
        else
        {
            $.ajax({
                url:'/deletePeople',
                type:'post',
                cache:false,
                dataType:'json',
                contentType:'application/json',
                data: JSON.stringify({
                    'idnum':idn,
                    'name':nam,
                    'password':adp,
                 }),
                success:function (data)
                {
                    if(data.code===0 || data.code==='0')
                    {
                        alert("已执行删除操作。");
                        window.location=window.location;
                        return;
                    }
                    else
                    {
                        alert("错误："+data.describe);
                        return;
                    }
                },
                error:function ()
                {
                    alert("出现不明原因错误。");
                    return;
                }
            })
        }

    });
    $(document).on('click','#People-SortById',function () 
    {
        NAMELIST_ARR.sort(function (a,b)
        {
            return parseInt(a['idnum'])-parseInt(b['idnum']);
        });
        PLT.html("");
        for(const ilab in NAMELIST_ARR)
        {
            const rt=parseInt(NAMELIST_ARR[ilab]['regtime'])/1000000;
            const sb_date=new Date(rt);
            const sb_date_str=sb_date.getFullYear().toString().padStart(4, '0')+"年"+(sb_date.getMonth()+1).toString().padStart(2, '0')+"月"+sb_date.getDate().toString().padStart(2, '0')+"日 "+
                        sb_date.getHours().toString().padStart(2, '0')+":"+sb_date.getMinutes().toString().padStart(2, '0')+":"+sb_date.getSeconds().toString().padStart(2, '0');
            const tr_temp=$('<tr></tr>');
            tr_temp.append($('<td></td>').html(NAMELIST_ARR[ilab]['idnum']))
            tr_temp.append($('<td></td>').html(NAMELIST_ARR[ilab]['name']))
            tr_temp.append($('<td></td>').html($.base64.decode(NAMELIST_ARR[ilab]['password'])))
            tr_temp.append($('<td></td>').html(sb_date_str));
            PLT.append(tr_temp);
        }

    });
    $(document).on('click','#People-SortByRegTime',function () 
    {
        NAMELIST_ARR.sort(function (a,b)
        {
            return parseInt(a['regtime'])-parseInt(b['regtime']);
        });
        PLT.html("");
        for(const ilab in NAMELIST_ARR)
        {
            const rt=parseInt(NAMELIST_ARR[ilab]['regtime'])/1000000;
            const sb_date=new Date(rt);
            const sb_date_str=sb_date.getFullYear().toString().padStart(4, '0')+"年"+(sb_date.getMonth()+1).toString().padStart(2, '0')+"月"+sb_date.getDate().toString().padStart(2, '0')+"日 "+
                        sb_date.getHours().toString().padStart(2, '0')+":"+sb_date.getMinutes().toString().padStart(2, '0')+":"+sb_date.getSeconds().toString().padStart(2, '0');
                    //console.log(sb_date_str);
            const tr_temp=$('<tr></tr>');
            tr_temp.append($('<td></td>').html(NAMELIST_ARR[ilab]['idnum']))
            tr_temp.append($('<td></td>').html(NAMELIST_ARR[ilab]['name']))
            tr_temp.append($('<td></td>').html($.base64.decode(NAMELIST_ARR[ilab]['password'])))
            tr_temp.append($('<td></td>').html(sb_date_str));
            PLT.append(tr_temp);
        }

    });
    $(document).on('click','#DeleteAssignment',function ()
    {
        const ida=prompt('请输入作业ID');
        const adp=prompt('请输入管理员密码：');
        const f=confirm('您是否删除该项作业？该操作不可撤销。');
        if(f===false)
        {
            alert("删除作业项目的操作已取消。");
            return;
            return;
        }
        else
        {
            $.ajax({
                url:'/deleteAssignment',
                type:'post',
                cache:false,
                dataType:'json',
                contentType:'application/json',
                data: JSON.stringify({
                    'assid':ida,
                    'password':adp,
                 }),
                success:function (data)
                {
                    if(data.code===0 || data.code==='0')
                    {
                        alert("已执行删除作业项目的操作。");
                        window.history.go(0);
                        return;
                    }
                    else
                    {
                        alert("错误："+data.describe);
                        return;
                    }
                },
                error:function ()
                {
                    alert("出现不明原因错误。");
                    return;
                }
            })
        }

    })

    $(document).on('click','#DpAssignment',function ()
    {
        const aname=prompt('请输入作业名称');
        const deadl=prompt('请输入截止时间，格式为2023-2-27-21-38-00')
        const adp=prompt('请输入管理员密码：');
        const f=confirm('您是否布置该项作业？');
        if(f===false)
        {
            alert("布置作业的操作已取消。");
            return;
            return;
        }
        else
        {
            var tempArr=deadl.split('-');
            var deadl_num=new Date(parseInt(tempArr[0]),parseInt(tempArr[1])-1,parseInt(tempArr[2]),parseInt(tempArr[3]),parseInt(tempArr[4]),parseInt(tempArr[5])).valueOf()

            $.ajax({
                url:'/deployAssignment',
                type:'post',
                cache:false,
                dataType:'json',
                contentType:'application/json',
                data: JSON.stringify({
                    'aname':aname,
                    'deadl':deadl_num,
                    'password':adp,
                 }),
                success:function (data)
                {
                    if(data.code===0 || data.code==='0')
                    {
                        alert("已执行布置作业项目的操作。");
                        window.history.go(0);
                        return;
                    }
                    else
                    {
                        alert("错误："+data.describe);
                        return;
                    }
                },
                error:function ()
                {
                    alert("出现不明原因错误。");
                    return;
                }
            });


        }
    })

    $(document).on('click','#SubmitState-idF',function ()
    {
        SUBMITLIST_ARR.sort(function (a,b)
        {
            return parseInt(a['idnum'])-parseInt(b['idnum']);
        });
        SLT.html("");
        for(const ilab in SUBMITLIST_ARR)
        {
            const rt=parseInt(SUBMITLIST_ARR[ilab]['submitTime']);
            const sb_date=new Date(rt);
            const sb_date_str=sb_date.getFullYear().toString().padStart(4, '0')+"年"+(sb_date.getMonth()+1).toString().padStart(2, '0')+"月"+sb_date.getDate().toString().padStart(2, '0')+"日 "+
                        sb_date.getHours().toString().padStart(2, '0')+":"+sb_date.getMinutes().toString().padStart(2, '0')+":"+sb_date.getSeconds().toString().padStart(2, '0');
            const tr_temp=$('<tr></tr>');
            tr_temp.append($('<td></td>').html(SUBMITLIST_ARR[ilab]['submitId']))
            tr_temp.append($('<td></td>').html(SUBMITLIST_ARR[ilab]['idnum']))
            tr_temp.append($('<td></td>').html(SUBMITLIST_ARR[ilab]['name']))
            tr_temp.append($('<td></td>').html(SUBMITLIST_ARR[ilab]['assignmentId']))
            tr_temp.append($('<td></td>').html(sb_date_str));
            SLT.append(tr_temp);
        }

    });

    $(document).on('click','#SubmitState-assF',function ()
    {
        SUBMITLIST_ARR.sort(function (a,b)
        {
            const a02=parseInt(a['assignmentId'])-parseInt(b['assignmentId']);
            if(a02===0)
            {
                return parseInt(a['idnum'])-parseInt(b['idnum'])
            }
            return a02;
        });
        SLT.html("");
        for(const ilab in SUBMITLIST_ARR)
        {
            const rt=parseInt(SUBMITLIST_ARR[ilab]['submitTime']);
            const sb_date=new Date(rt);
            const sb_date_str=sb_date.getFullYear().toString().padStart(4, '0')+"年"+(sb_date.getMonth()+1).toString().padStart(2, '0')+"月"+sb_date.getDate().toString().padStart(2, '0')+"日 "+
                        sb_date.getHours().toString().padStart(2, '0')+":"+sb_date.getMinutes().toString().padStart(2, '0')+":"+sb_date.getSeconds().toString().padStart(2, '0');
            const tr_temp=$('<tr></tr>');
            tr_temp.append($('<td></td>').html(SUBMITLIST_ARR[ilab]['submitId']))
            tr_temp.append($('<td></td>').html(SUBMITLIST_ARR[ilab]['idnum']))
            tr_temp.append($('<td></td>').html(SUBMITLIST_ARR[ilab]['name']))
            tr_temp.append($('<td></td>').html(SUBMITLIST_ARR[ilab]['assignmentId']))
            tr_temp.append($('<td></td>').html(sb_date_str));
            SLT.append(tr_temp);
        }

    });


    $(document).on('click','#SubmitState-timeF',function ()
    {
        SUBMITLIST_ARR.sort(function (a,b)
        {
            return parseInt(a['submitTime'])-parseInt(b['submitTime']);
        });
        SLT.html("");
        for(const ilab in SUBMITLIST_ARR)
        {
            const rt=parseInt(SUBMITLIST_ARR[ilab]['submitTime']);
            const sb_date=new Date(rt);
            const sb_date_str=sb_date.getFullYear().toString().padStart(4, '0')+"年"+(sb_date.getMonth()+1).toString().padStart(2, '0')+"月"+sb_date.getDate().toString().padStart(2, '0')+"日 "+
                        sb_date.getHours().toString().padStart(2, '0')+":"+sb_date.getMinutes().toString().padStart(2, '0')+":"+sb_date.getSeconds().toString().padStart(2, '0');
            const tr_temp=$('<tr></tr>');
            tr_temp.append($('<td></td>').html(SUBMITLIST_ARR[ilab]['submitId']))
            tr_temp.append($('<td></td>').html(SUBMITLIST_ARR[ilab]['idnum']))
            tr_temp.append($('<td></td>').html(SUBMITLIST_ARR[ilab]['name']))
            tr_temp.append($('<td></td>').html(SUBMITLIST_ARR[ilab]['assignmentId']))
            tr_temp.append($('<td></td>').html(sb_date_str));
            SLT.append(tr_temp);
        }

    });


    $.ajax({
        url:'/requireAllPeople',
        type:'post',
        cache:false,
        dataType:'json',
        contentType:'application/json',
        data: JSON.stringify({
                'admin_password':password
            }),
        success:function(data)
        {
            if(data.code==='0' || data.code===0)
            {
                //console.log(data.return_data)
                var return_data_arr = [];
                for(const ilab in data.return_data)
                {
                    return_data_arr.push(data.return_data[ilab]);
                }
                return_data_arr.sort(function (a,b)
                {
                    return parseInt(a['idnum'])-parseInt(b['idnum']);
                });
                NAMELIST_ARR=return_data_arr;

                for(const ilab in return_data_arr)
                {
                    //console.log();
                    const rt=parseInt(return_data_arr[ilab]['regtime'])/1000000;
                    const sb_date=new Date(rt);
                    const sb_date_str=sb_date.getFullYear().toString().padStart(4, '0')+"年"+(sb_date.getMonth()+1).toString().padStart(2, '0')+"月"+sb_date.getDate().toString().padStart(2, '0')+"日 "+
                        sb_date.getHours().toString().padStart(2, '0')+":"+sb_date.getMinutes().toString().padStart(2, '0')+":"+sb_date.getSeconds().toString().padStart(2, '0');
                    //console.log(sb_date_str);
                    const tr_temp=$('<tr></tr>');
                    tr_temp.append($('<td></td>').html(return_data_arr[ilab]['idnum']))
                    tr_temp.append($('<td></td>').html(return_data_arr[ilab]['name']))
                    tr_temp.append($('<td></td>').html($.base64.decode(return_data_arr[ilab]['password'])))
                    tr_temp.append($('<td></td>').html(sb_date_str));
                    PLT.append(tr_temp);
                }
            }
            else
            {
                warnings(data.describe);
                return;
            }


        },
        error:function()
        {
            warnings('人员信息加载出现了异常。');
            return;
        }

    })

    $.ajax({
        url:'/requireAllAssignment',
        type:'post',
        cache:false,
        dataType:'json',
        contentType:'application/json',
        data: JSON.stringify({
                'admin_password':password
            }),
        success:function(data)
        {
            if(data.code==='0' || data.code===0)
            {
                var return_data_arr = [];
                for(const ilab in data.return_data)
                {
                    return_data_arr.push(data.return_data[ilab]);
                }

                for(const ilab in return_data_arr)
                {
                    const tr_temp=$('<tr></tr>');
                    const sl=parseInt(return_data_arr[ilab]['startline'])/1000000;
                    const sl_date=new Date(sl);
                    const sl_date_str=sl_date.getFullYear().toString().padStart(4, '0')+"年"+(sl_date.getMonth()+1).toString().padStart(2, '0')+"月"+sl_date.getDate().toString().padStart(2, '0')+"日 "+
                        sl_date.getHours().toString().padStart(2, '0')+":"+sl_date.getMinutes().toString().padStart(2, '0')+":"+sl_date.getSeconds().toString().padStart(2, '0');

                    const dl=parseInt(return_data_arr[ilab]['deadline'])/1000000;
                    const dl_date=new Date(dl);
                    const dl_date_str=dl_date.getFullYear().toString().padStart(4, '0')+"年"+(dl_date.getMonth()+1).toString().padStart(2, '0')+"月"+dl_date.getDate().toString().padStart(2, '0')+"日 "+
                        dl_date.getHours().toString().padStart(2, '0')+":"+dl_date.getMinutes().toString().padStart(2, '0')+":"+dl_date.getSeconds().toString().padStart(2, '0');

                    tr_temp.append($('<td></td>').html(return_data_arr[ilab]['assid']));
                    tr_temp.append($('<td></td>').html(return_data_arr[ilab]['assignment']));
                    tr_temp.append($('<td></td>').html(sl_date_str))
                    tr_temp.append($('<td></td>').html(dl_date_str));
                    ALT.append(tr_temp);
                }
            }
            else
            {
                warnings(data.describe);
                return;
            }
        },
        error:function()
        {
            warnings('作业信息加载出现了异常。');
            return;
        }
    });



    $.ajax({
        url:'/requireAllSubmitState',
        type:'post',
        cache:false,
        dataType:'json',
        contentType:'application/json',
        data: JSON.stringify({
                'admin_password':password
            }),
        success:function(data)
        {
            if(data.code==='0' || data.code===0)
            {
                var return_data_arr = [];
                for(const ilab in data.return_data)
                {
                    return_data_arr.push(data.return_data[ilab]);
                }
                SUBMITLIST_ARR = return_data_arr;
                return_data_arr.sort(function (a,b)
                {
                    const a02=parseInt(a['assignmentId'])-parseInt(b['assignmentId']);
                    if(a02===0)
                    {
                        return parseInt(a['idnum'])-parseInt(b['idnum'])
                    }
                    return a02;
                })

                for(const ilab in return_data_arr)
                {
                    const tr_temp=$('<tr></tr>');
                    const sl=parseInt(return_data_arr[ilab]['submitTime']);
                    const sl_date=new Date(sl);
                    const sl_date_str=sl_date.getFullYear().toString().padStart(4, '0')+"年"+(sl_date.getMonth()+1).toString().padStart(2, '0')+"月"+sl_date.getDate().toString().padStart(2, '0')+"日 "+
                        sl_date.getHours().toString().padStart(2, '0')+":"+sl_date.getMinutes().toString().padStart(2, '0')+":"+sl_date.getSeconds().toString().padStart(2, '0');

                    tr_temp.append($('<td></td>').html(return_data_arr[ilab]['submitId']));
                    tr_temp.append($('<td></td>').html(return_data_arr[ilab]['idnum']));
                    tr_temp.append($('<td></td>').html(return_data_arr[ilab]['name']));
                    tr_temp.append($('<td></td>').html(return_data_arr[ilab]['assignmentId']))
                    tr_temp.append($('<td></td>').html(sl_date_str));
                    SLT.append(tr_temp);
                }
            }
            else
            {
                warnings(data.describe);
                return;
            }
        },
        error:function()
        {
            warnings('作业信息加载出现了异常。');
            return;
        }

    });



    $(document).on('click','#SS-BatchDelete',function ()
    {
        const ass=prompt('请输入将清除的作业ID');
        const adp=prompt('请输入管理员密码：');
        const f=confirm('您是否清除该ID下的所有作业？该操作不可撤销或恢复。');
        if(f===false)
        {
            alert("清除操作已取消。");
            return;
            return;
        }
        else
        {
            $.ajax({
                url:'/deleteAllF',
                type:'post',
                cache:false,
                dataType:'json',
                contentType:'application/json',
                data: JSON.stringify({
                    'assid':ass,
                    'password':adp,
                 }),
                success:function (data)
                {
                    if(data.code===0 || data.code==='0')
                    {
                        alert("已执行删除操作。");
                        window.history.go(0);
                        return;
                    }
                    else
                    {
                        alert("错误："+data.describe);
                        return;
                    }
                },
                error:function ()
                {
                    alert("出现不明原因错误。");
                    return;
                }
            })
        }

    });


    $(document).on('click','#SS-DownloadOne',function ()
    {
        const subid=prompt('请输入将下载的提交ID');
        const pass_02=prompt('请输入管理员密码');
        window.location="/downloadOneFile?subid="+subid+"&password="+pass_02;
    });
    $(document).on('click','#SS-DownloadAll',function ()
    {
        const pass_02=prompt('请输入管理员密码');
        window.location="/downloadAllFile?password="+pass_02;
    });

    $(document).on('click','#logout',function ()
    {
        $.removeCookie('admin_password');
        window.location='/';
    })

</script>
</body>
</html>
